<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>Document</title>
</head>
<body>
<input type="text" name="age" id="input"/>
<span id="msg"></span>

<script>
    let span = document.querySelector("#msg");
    document.querySelector("#input").addEventListener("keyup", function () {
        // if (this.value > 90) {
        //   msg = "年龄不能大于90岁";
        //   span.innerHTML = "<h2>" + msg + "</h2>";
        // }
        this.value > 90 ? (span.innerHTML = "<h2>年龄不能大于90岁</h2>") : "";
    });
</script>
</body>
</html>
